#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSortFilterProxyModel>

#include "ui_Mainwindow.h"

#include "Shop.h"
#include "Customer.h"
#include "ProductsModel.h"
#include "CustomersModel.h"
#include "InvoicesModel.h"
#include "ShopTreeModel.h"
#include "InvoiceItem.h"
#include "ProductsModelDelegate.h"

class MainWindow : public QMainWindow, private Ui::MainWindow
{
    Q_OBJECT
    
public:

    MainWindow( const ecocity::Shop& shop, QWidget *parent = 0 );
    
private slots:

    void on_actionSave_triggered( );
    void on_actionLoad_triggered( );

    void on_add_product_clicked( );
    void on_add_customer_clicked( );
    void on_new_invoice_clicked( );

    void on_delete_product_clicked( );
    void on_delete_customer_clicked( );
    void on_delete_invoice_clicked( );

    void show_products_from_proveider( QString proveider_name );
    void show_customer_type( QString customer_type );

    void update_product_price( QAbstractItemModel * model,
                               const QModelIndex& index,
                               float price );

private:

    void update_proveiders_combobox( );

    ecocity::Customer get_customer_from_dialog( );

    ecocity::Invoice get_invoice_from_dialog( const ecocity::Customer& );

    bool ok_to_delete( QWidget* parent, const QString& title, const QString& text );

private:

    ecocity::Shop m_shop;

    ProductsModel m_products_model;
    CustomersModel m_customers_model;
    ShopTreeModel m_shop_model;

    QStringList m_proveiders;
    QStringList m_price_types;

    QSortFilterProxyModel* products_filter_model;
    QSortFilterProxyModel* customers_filter_model;

    ecocity::ProductsModelDelegate* products_delegate;
};

#endif // MAINWINDOW_H
